package com.rd.student.ruanjian.class4.baiyunyao.DAY0728;

public   class deathlocked {


    Object A= new Object();
    Object B = new Object();
    Object C = new Object();
    public  void AtoBtoC(){
        synchronized (A){
            synchronized (B){
                synchronized (C){
                    System.out.println(Thread.currentThread().getName()+"A->B->C");
                }
            }
        }
    }
    public  void CtoAtoB(){
    synchronized (C){
        synchronized (A) {
            synchronized (B) {
                System.out.println(Thread.currentThread().getName() + "C->A->B");
            }
        }
    }
}
    public  void toto(){
        synchronized (B){
            synchronized (A) {
                synchronized (C) {
                    System.out.println(Thread.currentThread().getName() + "B->A->C");
                }
            }
        }
    }
}
